package com.jhx.demos.web.mapper;

import com.jhx.demos.web.pojo.BufferMessage;
import com.jhx.demos.web.pojo.Message;
import com.jhx.demos.web.pojo.User;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface UserMapper {


    /**
     * 查询所有留言信息
     *
     * @return
     */
    //    查询总记录数
//    @Select("select * from message")
//    List<Message> list();

    /*
    登录
    *@Param user
    *@Return
     */
    @Select("select *from user where username = #{username} and password = #{password}")
    User getByusernameandpassword(User user);


    /**
     * 分页查询
     * @param
     * @return
     */
    @Select("select * from message limit #{start},#{pageSize}")
    public List<Message> page(@Param("start") Integer start, @Param("pageSize") Integer pageSize);
    public List<Message> list(@Param("publisherID") Integer publisherID, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /*新增留言到缓冲区
    *@Param bmes
     */
    @Insert("insert into buffermessage (publisherID,datetime,content,status)values(#{publisherID},#{datetime},#{content},#{status})")
    void insert(BufferMessage bmes);


    /*利用映射文件进行批量删除操作
    *@Param ids
     */
    void delete(@Param("ids") List<Integer> ids);


    /*根据id查询留言信息
    *@Param id
    * @Return
     */
    @Select("select * from message where id =#{id}")
    Message find(Integer id);


    /*
    修改信息
    *@Param user
    * @Return
     */

    void update(Message mes);

    //员工信息注册
    @Insert("insert into user (id, password,e_mail, userType, username, status) VALUES (#{id},#{password},#{eMail},#{userType},#{username},#{status})")
    void register(User user);

}
